package com.quickfile.jrefilesystem;

import com.quickfile.File;
import com.quickfile.FileInputStream;
import com.quickfile.FileOutputStream;
import com.quickfile.FileSystemFactory;

public class FileSystemFactoryImpl implements FileSystemFactory {

	@Override
	public File newFile(String filepath) {
		return new FileImpl(filepath);
	}

	@Override
	public File newFile(String parent, String child) {
		return new FileImpl(parent, child);
	}

	@Override
	public File newFile(File parent, String child) {
		return new FileImpl(parent, child);
	}

	@Override
	public FileInputStream newFileInputStream(String filepath) {
		try {
			return new FileInputStreamImpl(filepath);
		} catch (Exception ex) {
			ex.printStackTrace();
			throw new RuntimeException(ex);
		}
	}

	@Override
	public FileInputStream newFileInputStream(File file) {
		try {
			return new FileInputStreamImpl(file);
		} catch (Exception ex) {
			ex.printStackTrace();
			throw new RuntimeException(ex);
		}
	}

	@Override
	public FileOutputStream newFileOutputStream(String filepath) {
		try {
			return new FileOutputStreamImpl(filepath);
		} catch (Exception ex) {
			ex.printStackTrace();
			throw new RuntimeException(ex);
		}
	}

	@Override
	public FileOutputStream newFileOutputStream(String filepath, boolean append) {
		try {
			return new FileOutputStreamImpl(filepath, append);
		} catch (Exception ex) {
			ex.printStackTrace();
			throw new RuntimeException(ex);
		}
	}

	@Override
	public FileOutputStream newFileOutputStream(File file) {
		try {
			return new FileOutputStreamImpl(file);
		} catch (Exception ex) {
			ex.printStackTrace();
			throw new RuntimeException(ex);
		}
	}

	@Override
	public FileOutputStream newFileOutputStream(File file, boolean append) {
		try {
			return new FileOutputStreamImpl(file, append);
		} catch (Exception ex) {
			ex.printStackTrace();
			throw new RuntimeException(ex);
		}
	}
}
